import { LayerInfoFE } from '@/pages/TemplateEditor/interface';

import { LayerTypeBE } from '../../constant';
import { LAYER_SIZE_LIMIT, PRODUCT_LAYER_SIZE_LIMIT } from './constant';

export const isTextLayer = (data: LayerInfoFE): boolean => {
  return data.data.type === LayerTypeBE.Text;
};

export const hasOtherLayers = (layers: LayerInfoFE[]): boolean => {
  return layers.length > 0;
};

export const isDisableNewLayer = (layers: LayerInfoFE[]): boolean => {
  return layers.length >= LAYER_SIZE_LIMIT;
};

export const isDisableProductLayer = (layers: LayerInfoFE[]): boolean => {
  return (
    layers.filter((layer) => layer.data.type === LayerTypeBE.Product).length >=
    PRODUCT_LAYER_SIZE_LIMIT
  );
};
